package com.itheima.tcp;

import java.io.*;
import java.net.Socket;

public class SocketDemoFour04 {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1", 1000);
        //本地流读取数据
        BufferedInputStream bu = new BufferedInputStream(new FileInputStream("day14\\Photo\\2.PNG"));
        //写到服务器
        OutputStream ou = socket.getOutputStream();
        BufferedOutputStream bufo = new BufferedOutputStream(ou);
        int b;
        while ((b = bu.read()) != -1) {
            bufo.write(b);//通过网络写到服务器
        }
        socket.shutdownOutput();
        BufferedReader bur = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        String line;
        while ((line = bur.readLine()) != null) {
            System.out.println(line);
        }
        socket.close();
        bu.close();
    }
}
